const Koa = require('koa');
const {createGzip} = require('zlib');
const {createReadStream,createWriteStream,readFileSync,writeFileSync} = require('fs');
const {pipeline} = require('stream');

const gzip = createGzip();
const source = createReadStream('index.html');
const destination = createWriteStream('index.html.gz');

const time1 = Date.now();
pipeline(source,gzip,destination,err => {
    if(err) {
        console.log('err:',err);
    }
})

const time2 = Date.now();
console.log(time2 - time1);

let file = readFileSync('index.html');
writeFileSync(file,'index1.html');

const time3 = Date.now();
console.log(time3 - time2);

